kexec: fail image loads if the page tables cannot be built
authorDavid Vrabel <david.vrabel@citrix.com>
Fri, 15 Nov 2013 10:00:46 +0000 (11:00 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 15 Nov 2013 10:00:46 +0000 (11:00 +0100)
CID 1128566

If an image source page is allocated in kimage_alloc_page() but the
machine_kexec_add_page() fails, the image may appear to load
succesfully but it will not execute.  The relocation will fault
(rebooting the host) when trying to copy the source page, as it is not
mapped.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/kimage.c

index 5c3e3b371f10c243b1e9b9d97eda0fdcbb8d78a5..91943f175a6108c959f2fd8c57de17e0c6946a09 100644 (file)
@@ -592,6 +592,7 @@ static struct page_info *kimage_alloc_page(struct kexec_image *image,
      */
     struct page_info *page;
     paddr_t addr;
+    int ret;
 
     /*
      * Walk through the list of destination pages, and see if I have a
@@ -656,7 +657,13 @@ static struct page_info *kimage_alloc_page(struct kexec_image *image,
         }
     }
 found:
-    machine_kexec_add_page(image, page_to_maddr(page), page_to_maddr(page));
+    ret = machine_kexec_add_page(image, page_to_maddr(page),
+                                 page_to_maddr(page));
+    if ( ret < 0 )
+    {
+        free_domheap_page(page);
+        return NULL;
+    }
     return page;
 }